package model;

import java.io.Serializable;

import javax.persistence.*;

import dtos.ExcursionPredTPDTO;


/**
 * The persistent class for the excursionPredTP database table.
 * 
 */
@Entity
@NamedQuery(name="ExcursionPredTP.findAll", query="SELECT e FROM ExcursionPredTP e")
public class ExcursionPredTP implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	private int excursionPredTPID;

	//bi-directional many-to-one association to PredefinedTP
	@ManyToOne
	@JoinColumn(name="travelID")
	private PredefinedTP predefinedtp;

	//bi-directional many-to-one association to Excursion
	@ManyToOne(cascade={CascadeType.PERSIST})
	@JoinColumn(name="excursionID")
	private Excursion excursion;

	public ExcursionPredTP() {
	}

	public int getExcursionPredTPID() {
		return this.excursionPredTPID;
	}

	public void setExcursionPredTPID(int excursionPredTPID) {
		this.excursionPredTPID = excursionPredTPID;
	}

	public PredefinedTP getPredefinedtp() {
		return this.predefinedtp;
	}

	public void setPredefinedtp(PredefinedTP predefinedtp) {
		this.predefinedtp = predefinedtp;
	}

	public Excursion getExcursion() {
		return this.excursion;
	}

	public void setExcursion(Excursion excursion) {
		this.excursion = excursion;
	}

	public boolean isInPredefinedTP(int travelID) {
		return (this.predefinedtp.getTravelID() == travelID);
	}

	public ExcursionPredTPDTO getDTO() {
		ExcursionPredTPDTO e = new ExcursionPredTPDTO();
		e.setExcursionPredID(this.excursionPredTPID);
		e.setExcursion(this.excursion.getDTO());
		e.setPredefinedTp(this.predefinedtp.getDTO());
		return e;
	}


}